{include file="Public:header2"/}
<body style="min-height: 100%;background-color: #fff">
<style>
    .qipao{
        position: absolute;
        top: 42%;
        left: 3%;
        border-radius: 36px;
        height: 45px;
        width: 45px;
        line-height: 45px;
        text-align: center;
        background-color: #e6e6e6;
    }
    .content_class{
        position: relative;
        border-bottom: 1px solid #999;
        width: 580px;
        margin-bottom: 33px;
    }
    .content_content{
        margin-left: 24px;
    }
    .kadengji{
        display: inline-block;
    }
    .kadengjio{
        margin-left: 130px;
    }
</style>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form onsubmit="return false;">
                        <div class="layui-form" wid100 lay-filter="">
                            <div class="content_class">
                                <div>
                                    <p class="qipao">左</p>
                                </div>
                                <div class="content_content">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">抽数</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="left_count" value="{if isset($card_set.left_count)}{$card_set.left_count}{/if}" placeholder="请输入抽数" autocomplete="off" class="layui-input"  style="width: 300px">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">标题</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="left_title" value="{if isset($card_set.left_title)}{$card_set.left_title}{/if}" placeholder="请输入标题" autocomplete="off" class="layui-input"  style="width: 300px">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">气泡提示</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="left_notice" value="{if isset($card_set.left_notice)}{$card_set.left_notice}{/if}" placeholder="请输入气泡提示" autocomplete="off" class="layui-input"  style="width: 300px">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label" style="width: 100%;text-align: left!important;">
                                            <a style="color: #01aaed;margin-left: 46px;cursor: pointer" onclick="prize_delete('left')">删除</a>
                                            <a style="color: #01aaed;margin-left: 10px;cursor: pointer" onclick="prize_add('left')">添加</a>
                                        </label>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">必出卡等级</label>
                                        <!--左卡等级js添加-->
                                        <div class="left_kadengji">
                                            {if isset($card_set['left_shang_id'])}
                                            {foreach $card_set['left_shang_id'] as $left_key => $left_vo}
                                            <div class="kadengji {if $left_key gt 0}kadengjio{/if}">
                                            <div class="layui-input-inline" style="width: 189px;display: inline-block">
                                                    <select name="left_shang_id[]" >
                                                        <option  value="">--请选择--</option>
                                                        {foreach name="shang" item="vo"}
                                                        <option value="{$vo.id}" {if $left_vo eq $vo.id} selected {/if}>{$vo.title}</option>
                                                        {/foreach}
                                                    </select>
                                                </div>
                                                <div class="layui-input-inline" style="width: 100px;display: inline-block">
                                                    <input type="text" name="left_shang_count[]" value="{$card_set['left_shang_count'][$left_key]}" placeholder="数量" autocomplete="off" class="layui-input">
                                                </div>
                                            </div>
                                            {/foreach}
                                            {/if}
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="content_class">
                                <div>
                                    <p class="qipao">中</p>
                                </div>
                                <div class="content_content">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">抽数</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="center_count" value="{if isset($card_set.center_count)}{$card_set.center_count}{/if}" placeholder="请输入抽数" autocomplete="off" class="layui-input"  style="width: 300px">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">标题</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="center_title" value="{if isset($card_set.center_title)}{$card_set.center_title}{/if}" placeholder="请输入标题" autocomplete="off" class="layui-input"  style="width: 300px">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">气泡提示</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="center_notice" value="{if isset($card_set.center_notice)}{$card_set.center_notice}{/if}" placeholder="请输入气泡提示" autocomplete="off" class="layui-input"  style="width: 300px">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label" style="width: 100%;text-align: left!important;">
                                            <a style="color: #01aaed;margin-left: 46px;cursor: pointer" onclick="prize_delete('center')">删除</a>
                                            <a style="color: #01aaed;margin-left: 10px;cursor: pointer" onclick="prize_add('center')">添加</a>
                                        </label>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">必出卡等级</label>
                                        <!--左卡等级js添加-->
                                        <div class="center_kadengji">
                                            {if isset($card_set['center_shang_id'])}
                                            {foreach $card_set['center_shang_id'] as $center_key => $center_vo}
                                            <div class="kadengji {if $center_key gt 0}kadengjio{/if}">
                                                <div class="layui-input-inline" style="width: 189px;display: inline-block">
                                                    <select name="center_shang_id[]" >
                                                        <option  value="">--请选择--</option>
                                                        {foreach name="shang" item="vo"}
                                                        <option value="{$vo.id}" {if $center_vo eq $vo.id} selected {/if}>{$vo.title}</option>
                                                        {/foreach}
                                                    </select>
                                                </div>
                                                <div class="layui-input-inline" style="width: 100px;display: inline-block">
                                                    <input type="text" name="center_shang_count[]" value="{$card_set['center_shang_count'][$center_key]}" placeholder="数量" autocomplete="off" class="layui-input">
                                                </div>
                                            </div>
                                            {/foreach}
                                            {/if}
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="content_class">
                                <div>
                                    <p class="qipao">右</p>
                                </div>
                                <div class="content_content">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">抽数</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="right_count" value="{if isset($card_set.right_count)}{$card_set.right_count}{/if}" placeholder="请输入抽数" autocomplete="off" class="layui-input"  style="width: 300px">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">标题</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="right_title" value="{if isset($card_set.right_title)}{$card_set.right_title}{/if}" placeholder="请输入标题" autocomplete="off" class="layui-input"  style="width: 300px">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">气泡提示</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="right_notice" value="{if isset($card_set.right_notice)}{$card_set.right_notice}{/if}" placeholder="请输入气泡提示" autocomplete="off" class="layui-input"  style="width: 300px">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label" style="width: 100%;text-align: left!important;">
                                            <a style="color: #01aaed;margin-left: 46px;cursor: pointer;" onclick="prize_delete('right')">删除</a>
                                            <a style="color: #01aaed;margin-left: 10px;cursor: pointer;" onclick="prize_add('right')">添加</a>
                                        </label>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">必出卡等级</label>
                                        <!--左卡等级js添加-->
                                        <div class="right_kadengji">
                                            {if isset($card_set['right_shang_id'])}
                                            {foreach $card_set['right_shang_id'] as $right_key => $right_vo}
                                            <div class="kadengji {if $right_key gt 0}kadengjio{/if}">
                                                <div class="layui-input-inline" style="width: 189px;display: inline-block">
                                                    <select name="right_shang_id[]" >
                                                        <option  value="">--请选择--</option>
                                                        {foreach name="shang" item="vo"}
                                                        <option value="{$vo.id}" {if $right_vo eq $vo.id} selected {/if}>{$vo.title}</option>
                                                        {/foreach}
                                                    </select>
                                                </div>
                                                <div class="layui-input-inline" style="width: 100px;display: inline-block">
                                                    <input type="text" name="right_shang_count[]" value="{$card_set['right_shang_count'][$right_key]}" placeholder="数量" autocomplete="off" class="layui-input">
                                                </div>
                                            </div>
                                            {/foreach}
                                            {/if}
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <input type="hidden" name="id" value="{$info.id}">
                                    <button class="layui-btn" onclick="return check()">确认保存</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
</body>
</html>
<script type="text/javascript">
    layui.use(['layer','form','upload','laydate'], function(){
        var $ = layui.$;
        var form = layui.form;
        var upload = layui.upload;
        var laydate = layui.laydate;

    });
    //卡等级赏
    var shang = {:json_encode($shang)};
    //必出添加
    function prize_add(type) {
        if(type == 'left'){
            var length = $(".left_kadengji .kadengji").length;
            var kadengjio = '';
            if(length >= 1){
                kadengjio = 'kadengjio';
            }
            var form = layui.form;
            var html = '';
                html +='<div class="kadengji '+kadengjio+'">';
                html +='<div class="layui-input-inline" style="width: 189px;display: inline-block">';
                html +='<select name="left_shang_id[]">';
                html +='<option  value="">--请选择--</option>';
                for (var i=0;i<shang.length;i++){
                    html +='<option  value="'+shang[i].id+'">'+shang[i].title+'</option>';
                }
                html +='</select>';
                html +='</div>';
                html +='<div class="layui-input-inline" style="width: 100px;display: inline-block">'
                html +='<input type="text" name="left_shang_count[]" value="" placeholder="数量" autocomplete="off" class="layui-input">'
                html +='</div>'
                html +='</div>';
            $(".left_kadengji").append(html);
            form.render();
        }else if(type == 'center'){
            var length = $(".center_kadengji .kadengji").length;
            var kadengjio = '';
            if(length >= 1){
                kadengjio = 'kadengjio';
            }
            var form = layui.form;
            var html = '';
            html +='<div class="kadengji '+kadengjio+'">';
            html +='<div class="layui-input-inline" style="width: 189px;display: inline-block">';
            html +='<select name="center_shang_id[]">';
            html +='<option  value="">--请选择--</option>';
            for (var i=0;i<shang.length;i++){
                html +='<option  value="'+shang[i].id+'">'+shang[i].title+'</option>';
            }
            html +='</select>';
            html +='</div>';
            html +='<div class="layui-input-inline" style="width: 100px;display: inline-block">'
            html +='<input type="text" name="center_shang_count[]" value="" placeholder="数量" autocomplete="off" class="layui-input">'
            html +='</div>'
            html +='</div>';
            $(".center_kadengji").append(html);
            form.render();
        }else if(type == 'right'){
            var length = $(".right_kadengji .kadengji").length;
            var kadengjio = '';
            if(length >= 1){
                kadengjio = 'kadengjio';
            }
            var form = layui.form;
            var html = '';
            html +='<div class="kadengji '+kadengjio+'">';
            html +='<div class="layui-input-inline" style="width: 189px;display: inline-block">';
            html +='<select name="right_shang_id[]">';
            html +='<option  value="">--请选择--</option>';
            for (var i=0;i<shang.length;i++){
                html +='<option  value="'+shang[i].id+'">'+shang[i].title+'</option>';
            }
            html +='</select>';
            html +='</div>';
            html +='<div class="layui-input-inline" style="width: 100px;display: inline-block">'
            html +='<input type="text" name="right_shang_count[]" value="" placeholder="数量" autocomplete="off" class="layui-input">'
            html +='</div>'
            html +='</div>';
            $(".right_kadengji").append(html);
            form.render();
        }
    }

    //必出删除
    function prize_delete(type) {
        if(type == 'left'){
            $(".left_kadengji .kadengji").last().remove();
        }else if(type == 'center'){
            $(".center_kadengji .kadengji").last().remove();
        }else if(type == 'right'){
            $(".right_kadengji .kadengji").last().remove();
        }
    }

    function check(){
        var url="{:url('/admin/card_goods_edit_number')}";
        var $ = layui.$;
        var load=layer.load(2);
        $.post(url,$("form").serialize(),function(data){
            if(data.status==1){
                layer.msg(data.msg,{icon:1,time:1500},function(){
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index);
                    parent.location.reload();
                });
            }else{
                layer.msg(data.msg,{icon:2,anim:6,time:1500},function(){
                    layer.close(load);
                });
            }
        })
    }


</script>
